package ch.unisi.inf.gui.action;

import java.awt.event.ActionEvent;
import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import ch.unisi.inf.engine.Image;
import ch.unisi.inf.engine.Library;

/**
 * @author bejarj@lu.unisi.ch
 *
 */
public class RemoveAction extends AbstractAction{
	final private JFrame frame;
	final private Library library;
	final private Image img;
	
	public RemoveAction(final JFrame frame, final Library library, final Image img){
		this.frame = frame;
		this.library = library;
		this.img = img;
		
		putValue(Action.NAME, "Remove");
		//putValue(Action.MNEMONIC_KEY, KeyEvent.VK_M);
		putValue(Action.SHORT_DESCRIPTION, "remove a photo");
	}

	public void actionPerformed(ActionEvent arg0) {
		if(JOptionPane.showConfirmDialog(frame, "You are removing a photo. \nAre you sure?","Remove", JOptionPane.YES_NO_OPTION)== JOptionPane.OK_OPTION)
		//System.out.println("you are removing a photo");
		if(library.getSize() == 0){
			System.out.println("the library is empty");
		}else{
			
		library.remove(img);
		
		}
	}

}
